package CS4310.csueb.characters;
import java.util.ArrayList;

import javax.swing.JFrame;

import CS4310.csueb.items.Armor;
import CS4310.csueb.items.Food;
import CS4310.csueb.items.Item;
import CS4310.csueb.items.KeyItem;
import CS4310.csueb.items.Shoe;
import CS4310.csueb.items.Weapon;
import CS4310.csueb.visual.BattleFrame;
import CS4310.csueb.visual.HeroSprite;
import CS4310.csueb.visual.Sprite;

/** Implementation of the Hero class, which inherits from the Character class.
 * This is the main character of the game.
 * 
 * @author Bikas Satpathy
 */
public class Hero extends Character {
	
	private Inventory inventory;
	private int currentHP;
	private int experience;
	
	public Hero (String name) {
		super(name);
		inventory = new Inventory();
		this.currentHP = this.getMaxHP();
		experience = 0;
	}

	public Hero (String name, int hp, int attack, int defense, int speed) {
		super(name, hp, attack, defense, speed);
		inventory = new Inventory();
	}
	
	//When Hero collects an item, it gets added into the appropriate inventory ArrayList
	public void collectItem (Item i) {
		//duplicate items cannot be collected. Will implement checking soon -Bikas
		inventory.addItem(i);
	}
	
	//Interact with other characters in the game
	public void interact(Character c) {
		//battle enemies and bosses.
		if (c instanceof Enemy) {
			
			//display a text bubble with the enemy/boss taunting Hero, then start battle
			new BattleFrame(new JFrame(),this, ((Enemy) c));
		}
		else if (c instanceof Boss) {
			new BattleFrame(new JFrame(), this, ((Boss) c));
		}
		else{
			//interact with friendly/neutral NPC so just display text bubble.
		}
	}
	
	//Retrieve the weapon list for the hero (used in the bio frame)
	// - Levester Chaney
	public ArrayList<Weapon> getWeapons() {
		return this.inventory.getWeaponsList();
	}
	
	//Retrieve the armor list for the hero (used in the bio frame)
	// - Levester Chaney
	public ArrayList<Armor> getArmor() {
		return this.inventory.getArmorList();
	}
	
	//Retrieve the key item list for the hero (used in the bio frame)
	// - Levester Chaney
	public ArrayList<KeyItem> getKeyItems() {
		return this.inventory.getKeyItemList();
	}
	
	//Retrieve the shoe list for the hero (used in the bio frame)
	// - Levester Chaney
	public ArrayList<Shoe> getShoes() {
		return this.inventory.getShoeList();
	}
	
	//Retrieve the food list for the hero (used in the bio frame)
	// - Levester Chaney
	public ArrayList<Food> getFood() {
		return this.inventory.getFoodList();
	}
	
	//for battling and stats, display the Hero's current HP, not max HP
	public int getCurrHP() {
		return this.currentHP;
	}
	
	//for battling or food usage, update the Hero's current HP
	//Negative diff means damage, positive means healing.
	public void setCurrHP(int diff) {
		if (diff >= 0) {
			this.currentHP = Math.min(this.getMaxHP(), this.currentHP + diff);
		}
		else this.currentHP = Math.max(0, this.currentHP + diff);
	}
	
	//for the BioFrame, returns the players current experience level
	public int getExp() {
		return this.experience;
	}
}
